import requests
import pprint
import time
start_time=time.time()
url='https://pvp.qq.com/web201605/js/herolist.json'
headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'
    }
response=requests.get(url,headers=headers)
data=response.json()#.json转换成列表或字典
#pprint.pprint(data)
for data1 in data:
    cname=data1['cname']#英雄名
    ename = data1['ename']  # id地址
    print(data1)
    try:
        skin_name = data1['skin_name'].split('|')  # 英雄皮肤名 split切割'|'获取英雄皮肤总数
    except Exception as e:
        pass
    #print(cname,ename,skin_name)
#     for skin_num in range(1,len(skin_name)+1):
#         #print(skin_name,skin_num)
#         #http://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/+英雄的ID值+'/'+英雄的ID值+'-bigskin-'+皮肤序号+.'jpg'
#         skin_url='http://game.gtimg.cn/images/yxzj/img201606/skin/hero-info/'+str(ename)+'/'+str(ename)+'-bigskin-'+str(skin_num)+'.jpg'
#         img_data=requests.get(skin_url,headers=headers).content
#         try:
#             with open('王者\\'+cname+'-'+'skin_name[skin_num-1]'+'.jpg','wb') as f:
#                 print('正在下载图片',cname+'-'+str(skin_name[skin_num-1]))
#                 f.write(img_data)
#         except OSError as e:
#             pass
# end_time=time.time()
# print('花费时间',end_time-start_time)

